import request from '@/utils/request'

export function login(data) {
    return request({
        url: '/api/users/login',
        method: 'post',
        data
    })
}

export function getInfo(token) {
    return request({
        url: '/api/users/info',
        method: 'get',
        params: { token }
    })
}

export function logout() {
    return request({
        url: '/api/users/logout',
        method: 'post'
    })
}

export function getUserList(params) {
    return request({
        url: '/api/users',
        method: 'get',
        params
    })
}

export function addUser(data) {
    return request({
        url: '/api/users',
        method: 'post',
        data
    })
}

export function updateUser(id, data) {
    return request({
        url: `/api/users/${id}`,
        method: 'put',
        data
    })
}

export function deleteUser(id) {
    return request({
        url: `/api/users/${id}`,
        method: 'delete'
    })
}